package com.example.demo.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("timer_settings")
public class TimerSettings implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("imei")
    private String imei;

    @TableField("product_id")
    private String productId;

    @TableField("relay_type")
    private String relayType; // 用于区分 main, relay1, relay2

    @TableField("enabled")
    private Boolean enabled;

    @TableField("on_time")
    private String onTime;

    @TableField("off_time")
    private String offTime;

    @TableField("`repeat`")
    private String repeat;

    // 可以添加一些辅助方法，例如：
    public boolean isValid() {
        return imei != null && productId != null && relayType != null;
    }

    @Override
    public String toString() {
        return "TimerSettings{" +
                "id=" + id +
                ", imei='" + imei + '\'' +
                ", productId='" + productId + '\'' +
                ", relayType='" + relayType + '\'' +
                ", enabled=" + enabled +
                ", onTime='" + onTime + '\'' +
                ", offTime='" + offTime + '\'' +
                ", repeat='" + repeat + '\'' +
                '}';
    }
}